<template>
  <view class="comment">
    <view class="content">
      <view class="tag" @tap="onMoreComment">
        <text>全部({{ commentData.number }})</text>
        <text>好评({{ commentData.praiseNumber }})</text>
        <text>中评({{ commentData.secondaryNumber }})</text>
        <text>差评({{ commentData.negativeNumber }})</text>
        <!-- <text>有图({{ commentData.picNumber }})</text> -->
      </view>
      <view class="items">
        <view class="item" v-for="(item, index) in commentList" :key="index">
          <view class="user">
            <view class="info">
              <image class="icon" :src="item.pic ? item.pic : '@/static/images/mine_user.png'" />
              <view class="nickname">{{ item.nickName ? item.nickName : '--' }}</view>
            </view>
            <text class="date">{{ item.recTime }}</text>
          </view>
          <view class="cmt-cnt">{{ item.content }}</view>
          <scroll-view class="cmt-attr" v-if="item.pics && item.pics.length" scroll-x="true">
            <image v-for="(commPic, index2) in item.pics" :key="index2" :src="commPic" />
          </scroll-view>
          <view class="cmt-reply" v-if="item.replyContent">
            <text class="reply-tit">店铺回复：</text>
            {{ item.replyContent }}
          </view>
        </view>
        <view class="empty" v-if="!commentList || !commentList.length">暂无评论</view>
      </view>
      <!-- <view class="cmt-more-v" v-if="commentList&&commentList.length > 2">
      <text @tap="onMoreComment">查看全部评价</text>
    </view> -->

      <!-- <view v-if="prodCommPage.pages > prodCommPage.current" class="load-more">
        <text @tap="getMoreCommPage">点击加载更多</text>
      </view> -->
    </view>
  </view>
</template>

<script setup>
import { ref, reactive, defineProps, onMounted } from 'vue';
const props = defineProps({
  commentData: {
    type: Object,
    default: () => {
      return null;
    }
  },
  commentList: {
    type: Object,
    default: () => {
      return [];
    }
  }
});

const onMoreComment = () => {};

onMounted(() => {
  console.log('接收2', props.commentData /* , props.commentList.list[0].nickName */);
});
</script>

<style lang="scss" scoped>
.comment {
  position: relative;
  line-height: 48rpx;
  margin-top: 20rpx;
  background: #fff;

  .content {
    padding: 0 20rpx;

    .tag {
      position: relative;
      padding: 10px 3px 0 0;
      margin: 0;

      text {
        display: inline-block;
        margin: 0 10px 10px 0;
        padding: 0 10px;
        height: 25px;
        line-height: 25px;
        border-radius: 3px;
        font-size: 12px;
        background: #fcedeb;
      }

      text.selected {
        color: #fff;
        background: #e93b3d;
      }
    }

    .items {
      .item {
        position: relative;
        padding: 10px 0;

        &::after {
          content: '';
          height: 0;
          display: block;
          border-bottom: 1px solid #ddd;
          position: absolute;
          left: 0;
          bottom: 0;
          right: -10px;
          border-bottom-color: #e5e5e5;
        }

        .user {
          line-height: 25px;
          margin-bottom: 8px;
          font-size: 12px;
          display: flex;
          justify-content: space-between;
          align-items: center;

          .info {
            display: flex;
            align-items: center;
            width: 400rpx;

            .icon {
              width: 25px;
              height: 25px;
              border-radius: 50%;
              vertical-align: middle;
            }

            .nickname {
              margin-left: 10px;
              display: inline-block;
              color: #333;
              max-width: 8.2em;
              height: 25px;
              line-height: 27px;
            }
          }

          .date {
            color: #999;
            font-size: 24rpx;
          }
        }
      }

      .empty {
        display: block;
        font-size: 24rpx;
        text-align: center;
        color: #aaa;
        margin-top: 5vh;
      }
    }
  }

  .cmt-cnt {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    position: relative;
    line-height: 1.5;
    font-size: 14px;
    margin: 5px 0;
    word-break: break-all;
    max-height: 126px;
  }

  .cmt-attr {
    height: 85px;
    width: 100%;
    white-space: nowrap;

    image {
      display: inline-block;
      width: 80px;
      height: 80px;
      margin-right: 5px;
      margin-bottom: 5px;
      border-radius: 2px;
      background: #f3f3f3;
    }
  }

  .cmt-more-v {
    text-align: center;
    background-color: #fff;
    font-size: 12px;

    text {
      height: 25px;
      line-height: 25px;
      font-size: 12px;
      text-align: center;
      color: #333;
      padding: 0px 10px;
      margin: 10px 0;
      border: 1px solid #ccc;
      border-radius: 40px;
      display: inline-block;
    }
  }

  .cmt-reply {
    font-size: 14px;
    border-top: 1px dashed #ddd;
    padding: 5px 0;

    .reply-tit {
      color: #e02e2e;
    }
  }
}
</style>
